import java.util.ArrayList;
import java.util.List;

public class Controller {
	
	public void run(BaseData data) {
		String jPath = "E:\\EclipseWork\\finance-manage\\points-finance-fetch-20180705\\src\\main\\java\\com\\jifen\\finance\\entity\\financeManager";
		String dPath = "E:\\EclipseWork\\finance-manage\\points-finance-fetch-20180705\\src\\main\\java\\com\\jifen\\finance\\dao\\financeManager";
		String xPath = "E:\\EclipseWork\\finance-manage\\points-finance-fetch-20180705\\src\\main\\resources\\mapper\\financeManager";
		
		String javaFullName = JavaTool.analysisFullName(jPath, data.getClassName());
		String javaPackageName = javaFullName.substring(0, javaFullName.lastIndexOf("."));
		String daoFullName = JavaTool.analysisFullName(dPath, data.getClassName()).concat("Dao");
		String daoPackageName = daoFullName.substring(0, daoFullName.lastIndexOf("."));
		
		
		List<String> javaImports = new ArrayList<String>();
		javaImports.add(javaFullName);
		List<String> daoImports = new ArrayList<String>();
		daoImports.add(javaFullName);
		daoImports.add("java.util.List");

		Java java = new Java();
		java.setImports(javaImports);
		java.setPackageName(javaPackageName);
		java.instance(data,jPath);
		Dao dao = new Dao();
		dao.setImports(daoImports);
		dao.setPackageName(daoPackageName);
		dao.instance(data,dPath);
		Xml xml = new Xml();
		xml.setDaoFullName(daoFullName);
		xml.setJavaFullName(javaFullName);
		xml.instance(data, xPath);
	}
	
	public static void main(String[] args) {
		Controller ctl=new Controller();
		BaseData data1 = new BaseData("time_machine","bg_loan_label");
		BaseData data2 = new BaseData("time_machine","bg_loan_product");
		BaseData data3 = new BaseData("time_machine","bg_loan_relative");
		ctl.run(data1);
		ctl.run(data2);
		ctl.run(data3);

	}
	
}
